<?php

namespace App\Http\Requests\Admin;

use App\Http\Controllers\Admin\AdminAuthController;
use App\Http\Requests\ApiRequest;
use Illuminate\Validation\Rules\In;

/**
 * @property string token
 * @property string type
 */
class RefreshTokenRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rule = [
            'type' => [ 'required','string', new In(AdminAuthController::ALL_LOGIN_TYPES)]
        ];

        if (! $this->bearerToken()) {
            $rule['token'] = 'required|string';
        }

        return $rule;
    }
}
